package com.unicom.xiyan.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2021/3/21 23:47
 * Description:
 */

@Configuration
public class EsConfig {

    @Bean
    public RestHighLevelClient getRestHighLevelClient() {
        RestClientBuilder restClientBuilder = RestClient.builder(
                new HttpHost("192.168.177.133", 9200, "http"),
                new HttpHost("192.168.177.133", 9201, "http"),
                new HttpHost("192.168.177.133", 9202, "http"));

        RestClient restClient = restClientBuilder.build();

        return new RestHighLevelClient(restClient);
    }
}
